<?php
function body($post) {
	$body = $post['Post']['body'];
	if(!isset($textile)) {
		App::import("Helper", "Extend.Textile");
	    $textile = new TextileHelper();
	}
	
	if (!empty($post['Image'])) {
		if(!isset($imageEmbed)) {
			App::import("Helper", "Extend.Embed");
			$imageEmbed = new EmbedHelper();
		}
		
		$body = $imageEmbed->substituteEmbedTags($body, $post['Image']);
	}
	
	return $textile->TextileThis($body);
	return strtoupper($body);
}

function rss_transform($item) {
	//debug($this);
	
	if (!empty($item['Image'])) {
		//$body = $imageEmbed->substituteEmbedTags($body, $item['Image']);
	}

	//$body = $textile->TextileThis($body);
	return array('title' => $item['Post']['title'],
				'link' => array('controller' => 'posts', 'action' => 'view', $item['Post']['slug']),
				'guid' => array('controller' => 'posts', 'action' => 'view', $item['Post']['slug']),
				'description' => body($item),
				'pubDate' => $item['Post']['date']				
				);
}

echo $rss->items($posts, 'rss_transform');
?>